import type { IPageResult, IResult } from '@/types/global';
import { request } from '@umijs/max';

import type {
  IAppMenuDO,
  ICreateCatalogRequest,
  ICreateMenuRequest,
  IUpdateCatalogRequest,
  IUpdateMenuRequest,
} from '@/types/systemManagement/menu';

// 获取应用菜单的树形结构，包括按钮
export async function postMenuFindWholeTree() {
  return request<IResult<IAppMenuDO[]>>('/corpus/knowledgePermission/getPermissionList', {
    method: "POST",
    data: {}
  });
}
//????
// 菜单管理列表
export async function postMenuFindTree(params: { appCode: string }) {
  return request<IResult<IAppMenuDO[]>>('/user-center/app/menu/find/tree', params);
}


// 菜单排序
export async function postMenuSort(params: { ids: number[] }) {
  return request<IResult<boolean>>('/app/menu/update/sort', params,);
}

// 新增目录
export async function postMenuCreateCatalog(params: Partial<ICreateCatalogRequest>) {
  return request<IResult<boolean>>('/app/menu/create/catalog', params,);
}

// 新增菜单
export async function postMenuCreateMenu(params: Partial<ICreateMenuRequest>) {
  return request<IResult<boolean>>('/app/menu/create/menu', params,);
}

// 删除菜单
export async function postMenuDelete(params: { id: number | string }) {
  return request<IResult<boolean>>('/app/menu/delete/menu', params,);
}

// 编辑菜单
export async function postMenuUpdateMenu(params: Partial<IUpdateMenuRequest>) {
  return request<IResult<boolean>>('/app/menu/update/menu', params,);
}

// 编辑目录
export async function postMenuUpdateCatalog(params: Partial<IUpdateCatalogRequest>) {
  return request<IResult<boolean>>('/app/menu/update/catalog', params,);
}
